﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class SearchLog : Form
    {
        public SearchLog()
        {
            InitializeComponent();
        }

        private void btn_back_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_search_Click(object sender, EventArgs e)
        {
            string start = "SELECT * FROM tbl_Logs WHERE";
            StringBuilder query = new StringBuilder();
            query.Append(start);
            if(chck_eid.Checked)
                query.Append(" AND fld_EmployeeID Like '" + txt_eid.Text + "'");
            if(chck_pid.Checked)
                query.Append(" AND fld_ProjectID Like '" + txt_pid.Text + "'");
            if (chck_lid.Checked)
                query.Append(" AND fld_LogID Like '" + txt_lid.Text + "'");
            try
            {
                query.Remove(start.Length + 1, 4);
                dgv_data.DataSource = SVProjects.searchLog(query.ToString());
            }
            catch
            {
                MessageBox.Show("Please choose at least one field", "Error");
            }
            
        }
    }
}
